package count

import (
	"fmt"
	"log"
)

func CountVotes() {
	lines, err := GetStrings("./count/votes.txt")
	if err != nil {
		log.Fatal(err)
	}

	//用映射处理统计过程
	counts := make(map[string]int) //创建map，键为string类型，值为int类型
	for _, line := range lines {
		counts[line]++
	}

	// fmt.Println(counts)

	//用for...range更新计票结果
	for name, count := range counts {
		fmt.Printf("Votes for %s： %d\n", name, count)
	}
}
